/**
 * 
 */
package org.gigi.security.repository.hibernate;

import javax.sql.DataSource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

/**
 * 抽象的持久化类
 * 
 * 同时提供jdbc和hibernate支持。
 *
 * @author Eugene Wang 2011-6-29
 * @see
 */
public abstract class AbstractHibernateRepository extends JdbcDaoSupport {
	@Autowired
	private SessionFactory sessionFactory;

	@Autowired
	public void setDataSouce(DataSource dataSource) {
		super.setDataSource(dataSource);
	}
	/**
	 * 获取当前Session
	 * @return
	 */
	protected Session getSession() {
		return sessionFactory.getCurrentSession();
	}
}
